<h2>Products</h2>
<div class="productlist">
	<div class="mblock clearfix listinfo">
		<div   class="pagination lblock">
		<?php
			if ($pagenum == 1) 
			{
			
			} else {	
				//echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=1'> <<-First</a> ";		
				echo " ";		
				$previous = $pagenum-1;		
				echo " <a href='{$_SERVER['PHP_SELF']}?pagenum/$previous' class='prv'>Previous</a> ";		
			}
			
			for ($rows = 1; $rows <= $last; $rows++)
			{
				if ($rows == $pagenum)
						echo "<a href='#' class='active'>" . $rows . "</a>";
					else
						echo "<a href='{$_SERVER['PHP_SELF']}?pagenum/$rows'>$rows</a>";
			}
			
			
			if ($pagenum == $last) {
				
			} else {	
				$next = $pagenum+1;		
				echo " <a href='{$_SERVER['PHP_SELF']}?pagenum/$next' class='nxt'>Next</a> ";		
				echo " ";		
				//echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$last'>Last ->></a> ";		
			}
		?>
		</div>
	</div>
	<div class="products">
		<?php
			/*echo "<pre>";
			print_r($product_arr);
			echo "</pre>";*/
			foreach ($product_arr as $product_entry) :
		?>
		<form name="frmProductDetails" method="POST" action="<?php echo SITEURL; ?>index.php/?addtocart">
			<div class="product">
				<div class="mblock clearfix inner">
					<div class="lblock pimage">
                 <?php 
                    $filePath= DOCROOT."images/products/thumbs/". $product_entry['filename'];
                    $imagePath= SITEURL."images/products/thumbs/". $product_entry['filename'];
                   
                     if(file_exists($filePath))
                     {
					?>	
                     <img src="<?php echo SITEURL; ?>images/products/thumbs/<?php echo $product_entry['filename']; ?>" border="0" alt="<?php echo $product_entry['product_title']; ?>" width="100" height="100" />
					<?php
                     }
                      else { ?>
                       <img src="<?php echo SITEURL; ?>images/products/thumbs/NoImage.jpg" border="0" alt="<?php echo $product_entry['product_title']; ?>" width="100" height="100" />
                   <?php } ?>
                    </div>
					<div class="rblock actions">
						<a href="<?php echo SITEURL; ?>index.php/?details/<?php echo $product_entry['productid']; ?>" class="details">Details</a>
						<div class="quadd">
							<label>Quantity :</label><input type="text" name="txtQty" id="txtQty" value="1" maxlength="5" size="2" onkeyup="validateQty('<?php echo $product_entry['productid']; ?>')" class="qinp" />
							<input type="submit" name="btnAddCart" value="Add to Basket" class="add" />
							<input type="hidden" name="productid" id="productid" value="<?php echo $product_entry['productid']; ?>" />
							<?php
								if(isset($_SESSION['savecartid']))
								{
							?>
							<input type="hidden" name="savecartid" id="savecartid" value="<?php echo $_SESSION['savecartid']; ?>" />
							<?php
								}
							?>
    <input type="hidden" name="price" id="price" value="<?php echo (!empty($product_entry['discount'])?$product_entry['discount']:$product_entry['product_price_lkr']); ?>" />
						</div>
					</div>
					<div class="rblock prices">
						Only : 
						<div class="formatedPrice"> 
							<?php 
								if(!empty($product_entry['discount']))
								{
							?>
								<s>LKR <?php echo number_format($product_entry['product_price_lkr'], 2, '.', ','); ?></s> LKR <?php echo number_format($product_entry['discount'], 2, '.', ','); ?>
							<?php 	
								} else {
									echo "LKR " . number_format($product_entry['product_price_lkr'], 2, '.', ','); 
								}
							?>
						</div>
					</div>
					<div class="cblock desc">
						<div class="title"><a href="<?php echo SITEURL; ?>index.php/?details/<?php echo $product_entry['productid']; ?>"><?php echo $product_entry['product_title']; ?></a></div>
						<!--<div class="SellingUnit"> 1 Each </div>-->
						<div class="webid">Item Number : <?php echo $product_entry['item_code']; ?></div>						
					</div>
				</div>
			</div>
		</form>
		<?php
			endforeach;
		?>
	</div>
	<div class="mblock clearfix listinfo">
		<div class="pagination lblock">
		<?php
			if ($pagenum == 1) 
			{
			
			} else {	
				//echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=1'> <<-First</a> ";		
				echo " ";		
				$previous = $pagenum-1;		
				echo " <a href='{$_SERVER['PHP_SELF']}?pagenum/$previous' class='prv'>Previous</a> ";		
			}
			
			if($last > 1)
			{
				for ($rows = 1; $rows <= $last; $rows++)
				{
					if ($rows == $pagenum)
							echo "<a href='#' class='active'>" . $rows . "</a>";
						else
							echo "<a href='{$_SERVER['PHP_SELF']}?pagenum/$rows'>$rows</a>";
				}
			}
			
			if ($pagenum == $last) {
				
			} else {	
				$next = $pagenum+1;		
				echo " <a href='{$_SERVER['PHP_SELF']}?pagenum/$next' class='nxt'>Next</a> ";		
				echo " ";		
				//echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$last'>Last ->></a> ";		
			}
		?>
		</div>
	</div>
</div>